給予一個整數,如果是偶數回傳 Even; 奇數回傳 Odd
(ns kata)
(defn even-or-odd [number]
(cond
(= (mod number 2) 0) "Even"
:else "Odd"
)
)
;; There's also "odd?" can be used to check whether is odd or not
(ns kata)
(defn even-or-odd [number]
(if (even? n) "Even" "Odd"))
回傳相反數
;; Same as (def name (fn [params* ] exprs*)) or (def name (fn ([params* ] exprs*)+))
(ns opposite-number)
(defn opposite number
(* number -1))
(ns opposite-number)
(def opposite -)